<?php
use yii\widgets\LinkPager;
use yii\helpers\Url;
use yii\widgets\Pjax;
use yii\helpers\Html;
use yii\helpers\ArrayHelper;

//use dosamigos\datepicker\DatePicker;
use kartik\datetime\DateTimePicker ;
$pageName = "日志列表";
$controller = Yii::$app->controller->id;
$action = Yii::$app->controller->action->id;
$this->title = $pageName . "-" . Yii::$app->params['webname'];
$this->params['breadcrumbs'][] = $pageName;
$this->params['display_name'] = $pageName;

$logArray = ['1'=>'error','4'=>'info'];

?>
<?php Pjax::begin(); ?>
<div class="row">
    <div class="col-md-12">
        <div class="nav-tabs-custom">
            <div class="tab-content">
                <div class="tab-pane active">
                        <form method="get" class="form-inline" action="<?= Url::toRoute(["$controller/index"]) ?>">
                            <div class="form-group">
                                <label class="control-label">关键字：</label>
                                <?= Html::input("text", "keyword",\Yii::$app->request->get('keyword'),["class"=>"form-control","placeholder"=>"日志类别、日志内容"]) ?>
                            </div>
                            <div class="form-group">
                                <label class="control-label">记录时间：</label>
                                <?= DateTimePicker::widget([
                                    'name' => 'start_time',
                                    'value' => \Yii::$app->request->get('start_time'),
                                    'options' => ['placeholder' => '开始时间', "class" => "form-control"],
                                    'pluginOptions' => [
                                        'language' => 'zh-CN',
                                        'autoclose' => true,
                                        'todayHighlight' => true,
                                    ]
                                ]);
                                ?>
                            </div>
                            <div class="form-group">
                                <label class="control-label">~</label>
                                <?= DateTimePicker::widget([
                                    'name' => 'end_time',
                                    'value' => \Yii::$app->request->get('end_time'),
                                    'options' => ['placeholder' => "结束时间", "class" => "form-control"],
                                    'pluginOptions' => [
                                        'language' => 'zh-CN',
                                        'autoclose' => true,
                                        'todayHighlight' => true,
                                    ]
                                ]);
                                ?>
                            </div>
                            <div class="form-group">
                                <label class="control-label">日志级别：</label>
                                <?= Html::dropDownList("level",\Yii::$app->request->get('level'),ArrayHelper::merge(['' => '=全部='],$logArray) , ["class" => "form-control"]) ?>
                            </div>
                            <div class="form-group">
                                <button class="btn btn-primary" type="submit">查询</button>
                            </div>
                        </form>
                </div>
                <div style="clear:both;"></div>
            </div>
            <div class="tab-content">
                <div class="tab-pane active">
                    <div class="box-body table-responsive no-padding">
                        <?php foreach ($logs as $log): ?>
                            <table class="table table-bordered table-striped  "
                                   style="margin-bottom: 50px;box-shadow: 14px 9px 5px #888888;">
                                <tbody>
                                <?php foreach ($log as $k => $item): ?>
                                <tr>
                                    <td style="width: 10%!important;"><?= $attributeLabels[$k] ?></td>
                                    <td><code style="word-wrap:break-word;word-break:break-all;"><?= $item ?></code></td>
                                </tr>
                                </tbody>
                                <?php endforeach; ?>
                            </table>
                        <?php endforeach; ?>
                    </div>
                    <div class="text-center">
                        <?=
                        LinkPager::widget([
                            'firstPageLabel' => '首页',
                            'lastPageLabel' => '末页',
                            'prevPageLabel' => '上一页',
                            'nextPageLabel' => '下一页',
                            'pagination' => $page,
                            'maxButtonCount' => 8,
                        ])
                        ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php Pjax::end(); ?>